package Java道题;

public class Hex {
    public static void hex(int decimal) {
        String hex = "";

        while (decimal != 0) {
            int hexValue = decimal % 16;
            char hexDigit = (hexValue <= 9 && hexValue >= 0) ? (char) (hexValue + '0') : (char) (hexValue - 10 + 'A');
            hex = hexDigit + hex;
            decimal = decimal / 16;
        }
        System.out.println("The hex number is:" + hex);
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        hex(1230);
    }

}
